package com.example.smartagrisys.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.smartagrisys.entity.Notification;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * 消息通知Mapper接口
 */
@Mapper
public interface NotificationMapper extends BaseMapper<Notification> {

    /**
     * 将用户所有未读消息标记为已读
     *
     * @param userId 用户ID
     * @return 影响的行数
     */
    @Update("UPDATE notification SET is_read = true, read_time = NOW() WHERE user_id = #{userId} AND is_read = false AND deleted = false")
    int markAllAsRead(@Param("userId") Long userId);
} 